package com.example.controller;

import com.example.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author fyxw
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @ResponseBody
    @PostMapping(produces = "text/pain;charset=utf-8")
    public String addUser(User user) {
        System.out.println(user);
        return user.toString();
    }

    @ResponseBody
    @PutMapping(produces = "text/pain;charset=utf-8")
    public String updateUser(User user) {
        System.out.println(user);
        return user.toString();
    }

    @ResponseBody
    @DeleteMapping(produces = "text/pain;charset=utf-8", value = "/{id}")
    public String deleteUser(@PathVariable int id) {
        return "删除的ID为：" + id;
    }

    @ResponseBody
    @GetMapping(value = "/{id}", produces = "text/pain;charset=utf-8")
    public String getUser(@PathVariable int id) {
        return "获取的User ID：" + id;
    }
}
